package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询对应套餐id
     * @param ids
     * @return
     */
    // select setmeal_id from setmeal_dish where dish_id in (ids)
    List<Long> getSetmealByIds(List<Long> ids);

    /**
     * 批量新增套餐菜品关联关系
     * @param setmealDishes
     */
    void addSetmealDishes(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id删除套餐菜品关联关系
     * 批量删除
     * @param setmealIds
     */
    void deleteSetmealDishBench(List<Long> setmealIds);

    /**
     * 根据套餐id查询套餐菜品关联关系
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> querySetmealDishesBySetmealId(Long id);

    /**
     * 根据套餐id查询菜品
     * 多表查询
     * @param setmealId
     * @return
     */
    List<Dish> queryDishesBySetmealId(Long setmealId);

    /**
     * 根据套餐id删除套餐菜品关联关系
     * 单条删除
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteSetmealDishById(Long setmealId);
}
